#ifndef _SOFTWARE_UART_H_
#define _SOFTWARE_UART_H_


#include "../../bitarray/BitArray.h"
#include "../../shifter/Shifter.h"



/*
	class : SoftwareUart
	desc : Software implementation of the uart protocol
*/
class SoftwareUart
{
	public :
	//configuration for the software uart
typedef struct SoftwareUART_CONFIG
{
	unsigned char dataSize : 3;
	unsigned char stopNumber : 1;
	unsigned char polarity : 1; 
	unsigned char parity : 2;
	unsigned char io : 1;
	unsigned char finished : 1;
}
UartConfig;

	//the shifter I am using to do this.
	private:
		//configuration for the software uart
		UartConfig config;
		//shifter used to implement the uart
		Shifter shifter;
		//pointer to output bit for uart.
		BitPointer bit;

	public:
	//enumerates io direction
enum IODirection { Input, Output };
	//enumerates polarity
enum Polarity { High=1, Low=0 };
	//enumerates parity
enum Parity { NoParity, EvenParity, OddParity };
	//enumerates stops
enum Stops { OneStop=0, TwoStop=1 };


		//default constructor
		SoftwareUart();
		//constructor takes in config and a pointer
		SoftwareUart(SoftwareUartConfig c, BitPointer& b);
		//sets word to be transmitted
		void set(unsigned char data);
		//gets word transmitted
		unsigned char get(bool& parityChoice);
		//should move this to bit or something.
		static unsigned char calculateParity(unsigned char parityChoice, 
							unsigned char data);
		//runs the protocol 
		void run();
		//determines if finished sending or receiving.
		bool getFinished();

};


#endif
